package com.controller;

import com.pojo.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class ProductController {
    //    @RequestMapping("/getproducts")
//    public void getProducts(String[] poIds) {
//        for (String poId:poIds){
//            System.out.println("poId="  + poId);
//        }
//    }
    @RequestMapping("/getproducts")
    public void getProducts(@RequestParam("poIds") List<String> poIds) {
        for (String poId : poIds) {
            System.out.println("poId=" + poId);
        }
    }

    @RequestMapping("/getProduct")
    public void getProduct(@RequestBody List<Product> product) {
        System.out.println("product.getProId()=" + product.get(0).getProId() );
        System.out.println("product.getProName()=" + product.get(0).getProName() );
    }

    @RequestMapping("/getProductlist")
    public void getProductlsit(@RequestBody List<Product> products) {
        for (Product product : products) {
            String proId = product.getProId();
            String proName = product.getProName();
            System.out.println("获取到的Id为="+proId+"名称为="+proName);
        }
    }
}
